from django.conf.urls import url
# from . import views_old
from . import views
from rest_framework.routers import DefaultRouter

# 实例化路由器
router = DefaultRouter()
# 注册类视图
router.register(r'books', views.BookInfoViewSet,base_name='books')

urlpatterns = [
    # url(r'books/$', views.BooksView.as_view()),
    # url(r'books/(?P<id>\d+)/$', views.BooksView.as_view())
    # APIView的路由
    url(r'books/$', views.BookInfoView.as_view()),
    url(r'books/(?P<pk>\d+)$', views.BookDetailView.as_view()),
    url(r'books/')
]

# print(router.urls)
# 添加url到urlpatterns
# urlpatterns += router.urls
